/**
 * Weapon.java
 */
// $codepro.audit.disable numericLiterals
package edu.gatech.startrader.ship;

import java.util.Random;

/**
 * Weapon Enumerated Type
 * The types of weapons a ship can have
 * @author Team Bamf (Team 30)
 */
public enum Weapon {
	/**
	 * A pulse laser is the cheapest and weakest laser
	 */
	PULSE_LASER(1200,5,0.35),
	
	/**
	 * A beam laser is the middle priced laser that has medium power
	 */
	BEAM_LASER(3500,100,0.45),
	
	/**
	 * A military laser is the best and most expensive laser
	 */
	MILITARY_LASER(8500,15,0.55);
	
	/**
	 * The price of the Weapon in any planet's shipyard
	 */
	private final int price;
	
	/**
	 * How powerful this weapon is
	 */
	private final int attackPower;
	
	/**
	 * How often the weapon will hit
	 */
	private final double accuracy;
	
	/**
	 * RNG related to weapon attacks
	 */
	private static final Random RNG = new Random();
	
	/**
	 * Creates a Weapon object
	 * @param weaponPrice price of the weapon
	 * @param weaponAttack attackPower of the weapon
	 * @param weaponAccuracy accuracy of the weapon
	 */
	private Weapon(int weaponPrice, int weaponAttack, double weaponAccuracy) {
		price = weaponPrice;
		attackPower = weaponAttack;
		accuracy = weaponAccuracy;
	}
	
	/**
	 * gets how expensive the shield is
	 * @return the price of the weapon
	 */
	public int getPrice() {
		return price;
	}
	
	/**
	 * gets how powerful the weapon is on how much will 
	 * be deducted from a ship's hull if it hits
	 * @return the attack power of the weapon
	 */
	public int getAttackPower() {
		return attackPower;
	}
	
	/**
	 * Checks whether a weapon hits an enemy or not
	 * @param targetSystemCheck whether or not the 
	 * ship has a a Targeting System Gadget
	 * @return whether it hits or not
	 */
	public boolean canHit(boolean targetSystemCheck) {
		final double check = ((targetSystemCheck) ? 1.5 : 1) * accuracy;
		return (RNG.nextDouble() > check);
	}
}
